//
//  SearchGeocodeResultModel.m
//  o_amap
//
//  Created by Q神 on 2021/4/20.
//

#import "SearchGeocodeResultModel.h"

@implementation SearchGeocodeResultModel

+ (NSDictionary *)mj_objectClassInArray {
    return @{@"geocodeAddressList": @"GeocodeModel"};
}

+ (SearchGeocodeResultModel *)createGeocodeResultModelWithResponse:(AMapGeocodeSearchResponse *)response {
    SearchGeocodeResultModel *model = [[SearchGeocodeResultModel alloc] init];
    NSMutableArray<GeocodeModel *> * arrays = [NSMutableArray array];
    for (AMapGeocode *geo in response.geocodes) {
        GeocodeModel *geocodeModel = [[GeocodeModel alloc] init];
        geocodeModel.formatAddress = geo.formattedAddress;
        geocodeModel.province = geo.province;
        geocodeModel.city = geo.city;
        geocodeModel.citycode = geo.citycode;
        geocodeModel.district = geo.district;
        geocodeModel.adcode = geo.adcode;
        geocodeModel.township = geo.township;
        geocodeModel.neighborhood = geo.neighborhood;
        geocodeModel.building = geo.building;
        geocodeModel.level = geo.level;
        geocodeModel.country = geo.country;
        geocodeModel.postcode = geo.postcode;
        geocodeModel.latLng = [LatLngModel initWithLat:geo.location.latitude
                                                 withLng:geo.location.longitude];
        
        [arrays addObject:geocodeModel];
    }
    model.geocodeAddressList = arrays;
    return model;
}

@end


@implementation GeocodeModel

@end
